<!-- 简历管理 -->
<!-- 招聘管理 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label mb10">招聘管理</p>
    <dxtable
      :dataJson="dataJson"
      :portUrl="portUrl"
      :formJson="formJson"
      :qx="qx"
      ref="databale"
      :czFun="czFun"
    ></dxtable>
    <n-modal v-model:show="showModal" preset="card" class="Stock-diagnosis">
      <template #header>面试安排</template>
      <n-form
        ref="formRef"
        :model="xxfrom"
        :rules="rules"
        label-placement="left"
        label-width="120"
      >
        <!-- <n-form-item label="面试时间">
          <n-date-picker
            v-model:value="kdsfdsrt"
            type="datetime"
            clearable
          />
        </n-form-item>
        <n-form-item path="msdd" label="面试地点">
          <n-input
            v-model:value="xxfrom.msdd"
            type="text"
            placeholder="面试地点"
          />
        </n-form-item> -->
        <n-form-item path="beizhu" >
          <n-input
            v-model:value="xxfrom.beizhu"
            type="textarea"
            placeholder="面试安排明细"
          />
        </n-form-item>
      </n-form>
      <template #action>
        <div class="tr">
          <n-button type="info" @click="jjsdfsdrtt" :loading="losdfds">
            确认
          </n-button>
          <n-button @click="showModal = false" class="ml20"> 取消 </n-button>
        </div>
      </template>
    </n-modal>
  </div>
</template>
<script lang="ts" setup>
import { Options } from "@vicons/ionicons5";
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import { dxget, dxpost, transferTimeYMDHm } from "../../util/index";
import { NButton, NImage, NTag } from "naive-ui";
import { h, ref, reactive, render } from "vue";
const databale = ref();
const dqobj = ref({});
const initeer = () => {
  databale.value.initDataExpose();
};
const showModal = ref(false);
const kdsfdsrt = ref()
const xxfrom = ref({
  uid: "",
  zwid: "",
  beizhu: "",
});

const formRef = ref();
const rules = {
  mssj: {
    required: true,
    message: "请选择面试时间",
    trigger: ["blur", "change"],
  },
  msdd: {
    required: true,
    message: "请输入面试地点",
    trigger: "blur",
  },
};
let losdfds = ref(false);
const jjsdfsdrtt = () => {
  formRef.value?.validate(async (errors) => {
    if (!errors) {

      xxfrom.value.zwid = dqobj.value.zwid;
      xxfrom.value.uid = dqobj.value.uid;
      losdfds.value = true;

      await dxpost("jyc/miansi/miansi", xxfrom.value);
      await dxpost(
        "jyc/jianli/jianli",
        {
          id: dqobj.value.id,
          ismiansi: "是",
        },
        "put"
      );

      try{
        await dxpost("jyc/jycadmin/putongrizhi", {
        id:dqobj.value.uid,
        name:dqobj.value.name,
        beizhu: xxfrom.value.beizhu,
        czlx: "面试邀请",
      });
      }catch(e){

      }

      initeer();
      losdfds.value = false;
      showModal.value = false;
    }
  });
};

let dataJson = [
  {
    title: "职位名称",
    key: "jianli.zwid",
    width: "",
    type: "select",
    options: [],
    search: true,
    istable: true,
    required: false,
    render: (row) => {
      return row.name;
    },
  },
  {
    title: "试用期价格",
    key: "syqjg",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "薪资待遇",
    key: "xzdy",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "工作地点",
    width: "",
    search: false,
    istable: true,
    required: false,
    render: (row) => {
      return row.sheng + "-" + row.shi;
    },
  },
  {
    title: "投递人姓名",
    key: "jianli.uid",
    width: "",
    type: "select",
    options: [],
    search: true,
    istable: true,
    required: false,
    render(row) {
      return row.uname;
    },
  },
  {
    title: "投递人电话",
    key: "phone",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "简历地址",
    width: 100,
    render(row) {
      return h(
        "span",
        {
          class: "ls sz",
          onClick() {
            open(row.text);
          },
        },
        "点击查看"
      );
    },
  },
  {
    title: "是否安排面试",
    key: "ismiansi",
  },
  {
    title: "投递时间",
    key: "addTime",
    width: 150,
  },
];

const qx = {
  DeletePermissionID: "jyczhaopingdel", //删除
  EditPermissionIdentifier: "23456", // 编辑
  NewPermissionIdentifier: "23456", // 新建
  ViewPermissionID: "jyczhaopingck", // 查看
};
const portUrl = "jyc/jianli/jianli";

let formJson = reactive([]);
const czFun = {
  fun: (row) => {
    return [
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {
            if (row.ismiansi == "是") {
              window.$message.error("已安排了面试");
              return;
            }
            dqobj.value = row;
            showModal.value = true;
          },
        },
        row.ismiansi == "是" ? "已安排" : "安排面试"
      ),
    ];
  },
};

const getgetuserList = async () => {
  const { data }: any = await dxget("jyc/api/getuserList");
  dataJson[4].options = [
    {
      label: "全部",
      value: "",
    },
    ...data,
  ];
};
getgetuserList();

const getzhiwei = async () => {
  const { data }: any = await dxget("jyc/api/getzhiwei");
  dataJson[0].options = [
    {
      label: "全部",
      value: "",
    },
    ...data,
  ];
};
getzhiwei();
</script>
<style scoped></style>
